// react.lazy的实现
function lazy(load) {
    return class extends React.Component {
        state = {
            component: null
        }
        componentDidMount() {
            load().then(component => {
                this.setState({ component: component.default || component })
            })
        }

        render() {
            let { component: TrueComponent } = this.state
            if (TrueComponent) {
                return <TrueComponent {...this.props}></TrueComponent>
            } else {
                return null
            }
        }
    }
}
let LazyHome = lazy(() =>
    import(/* webpackChunkName: "Home" */'./components/Home')
)


function SuspenseHome() {

    return (
        <React.Suspense fallback={<div>loaing</div>}>
            <LazyHome></LazyHome>
        </React.Suspense>
    )
}